package session2.overloaded;

public class UseAnimals {

	public UseAnimals() {

	}

	// // override; ko tac dung
	// public void doStuff() {
	// System.out.println("UseAnimals.java: doStuff()");
	// }

	public void doStuff(Animal a) {
		System.out.println("Horse.java: doStuff(Animal a)");
	}

	public void doStuff(Horse h) {
		System.out.println("Horse.java: doStuff( Horse h)");
	}

	public static void main(String[] args) {
		Animal aniObj = new Animal();
		Horse horseObj = new Horse();

		UseAnimals ua = new UseAnimals();
		ua.doStuff(aniObj);// Horse.java: doStuff(Animal a)
		ua.doStuff(horseObj);// Horse.java: doStuff( Horse h)

		// Cha tro den con, dung method cua cha;
		Animal aniRefToHorse = new Horse();
		// aniRefToHorse.doStuff();// Su dung method doStuff() cua Animal;
		// KQ: Animal.java: doStuff()

		ua.doStuff(aniRefToHorse);// Horse.java: doStuff(Animal a)
		// Trong sach, p78/457 co noi rang ket qua tra ve la method cua class
		// Animal, =>Dieu nay ko dung;
	}
}